<template>
    <c-list-template title="出口手续管理" :operation="true">
        <template slot="search">
            <el-row :gutter="5">
                <el-col :span="6" class="flex-center ">
                    <div class="mr-lg">车辆信息</div>
                    <el-input v-model="querys.keyword" placeholder="请输入查询的车辆信息" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="6" class="flex-center ">
                    <div class="mr-lg">供应商名称</div>
                    <el-input v-model="querys.sellerName" placeholder="请输入供应商名称" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="6" class="flex-center ">
                    <div class="mr-lg">车架号</div>
                    <el-input v-model="querys.vin" placeholder="请输入车架号" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="6" class="flex-x-end">
                    <el-button icon="el-icon-search" type="primary" @click="handleSelect">搜索</el-button>
                    <el-button icon="el-icon-delete" @click="handleReset">重置</el-button>
                </el-col>
            </el-row>
        </template>
        <template slot="list">
            <el-table :header-cell-style="{ background: '#F1F1F1', color: '#092132' }" :data="tableData" v-loading="loading">
                <el-table-column label="序号" align="center" width="80" type="index" />
                <el-table-column width="" label="车辆信息" align="center" prop="name">
                    <template slot-scope="scope">
                        {{ scope.row.brand }}- {{ scope.row.series }}- {{ scope.row.model }}
                    </template>
                </el-table-column>
                <el-table-column width="" label="车架号" align="center" prop="vin" />
                <el-table-column width="" label="出口申请单号" align="center" prop="carOutApplyId" />
                <el-table-column width="" label="供应商名称" align="center" prop="sellerName" />
                <el-table-column width="" label="更新时间" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.timeModify | dateYMDHMSFormat }}
                    </template>
                </el-table-column>
                <!-- <el-table-column width="" label="状态" align="center" prop="" /> -->
                <el-table-column width="" label="操作" align="center">
                    <template slot-scope="scope">
                        <el-link type="primary" v-if="scope.row.detectionReportUploaded" @click="handleLetter(scope.row,1)" :underline="false">上传检测证明</el-link>
                        <el-link type="primary" v-if="scope.row.exportProceduresUploaded" @click="handleLetter(scope.row,2)" :underline="false">上传转移待出口手续</el-link>
                        <el-link type="primary" v-if="!scope.row.detectionReportUploaded && !scope.row.exportProceduresUploaded" @click="handleDetails(scope.row)" :underline="false">查看手续</el-link>
                    </template>
                </el-table-column>
            </el-table>
        </template>
        <template slot="pagination">
            <el-pagination background :current-page="querys.current" :page-sizes="[10, 20, 50, 100]" :page-size="querys.size" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </template>
        <c-letter-upload ref="cLetterUpload" />
    </c-list-template>

</template>
<script>
import cLetterUpload from "../components/c-letter-upload.vue";
export default {
    components: {
        cLetterUpload,
    },
    data () {
        return {
            total: 0,
            tableData: [],
            querys: {
                current: 1,
                size: 10,
            },
            loading: false,
        };
    },
    mounted () {
        this.tableList();
    },
    methods: {
        handleDetails (item) {
            this.$router.push({
                path: "/procedures/export/details",
                query: {
                    id: item.id
                },
            });
        },
        handleLetter (item, type) {
            let url = {
                1: "/carList/checkReport/upload",
                2: "/carList/outProcedure/upload"
            }[type];
            this.$refs.cLetterUpload.handleOpen(item, url);
        },
        tableList () {
            this.loading = true;
            const params = JSON.parse(JSON.stringify(this.querys));
            const url = "/carList/searchCarListWithFiles";
            this.$get({ url, params }).then((res) => {
                this.tableData = res.records;
                this.total = res.total * 1;
                this.loading = false;
            });
        },
        handleReset () {
            this.querys = {
                current: 1,
                size: 10,
            };
            this.tableList();
        },
        handleSelect () {
            this.querys.current = 1;
            this.tableList();
        },
        handleSizeChange (val) {
            this.querys.size = val;
            this.tableList();
        },
        handleCurrentChange (val) {
            this.querys.current = val;
            this.tableList();
        },
    },
};
</script>
